// pages/home/home.js
import {axios} from "../../api/http.js";
import {get_Commodity,GetSlideshow} from "../../api/Url.js"
Page({
  gotodetails:function(e){
     wx.redirectTo({
       url: '../details/details?Id='+e.currentTarget.dataset.id,
     })
  },
  gotoinput:function(){
    wx.navigateTo({
      url: '../input/input',
    })
  },
  gotosale:function(){
   wx.navigateTo({
      url:"../sale/sale"
    })
  },
  data:{
    list:"",
    swiperCurrent: 0,
    indicatorDots: true,
    autoplay: true,
    interval: 3000,
    duration: 800,
    circular: true,
    indicatorCo:"#ffdfdc",
    indicatoraAC:"#ff948a",
    imgUrls: [],
    links: [
      '../user/user',
      '../user/user',
      '../user/user'
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    axios(get_Commodity,{commodityClassify:"主页"},"GET",(res)=>{
      console.log(res)
      this.setData({
        list:res
      })
    })
    axios(GetSlideshow,{},"get",(res)=>{
      console.log(res)
      this.setData({
        imgUrls:res
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  swiperChange: function (e) {
 
    this.setData({
 
      swiperCurrent: e.detail.current
 
    })
 
  },
 
  //点击指示点切换
 
  chuangEvent: function (e) {
 
    this.setData({
 
      swiperCurrent: e.currentTarget.id
 
    })
 
  },
 
  //点击图片触发事件
 
  swipclick: function (e) {
    wx.redirectTo({
      url: '../details/details?Id='+e.currentTarget.dataset.slideshowphotoid,
    })
  }

})